//懒加载的其他写法2：
export default [
	{
		path: "/",
		redirect: "/home",
	},
	{
		path: "/login",
		name: "login",
		component: () => import("@/pages/Login"),
		meta: {
			isHidden: true,
		},
	},
	{
		path: "/register",
		name: "register",
		component: () => import("@/pages/Register"),
		meta: {
			isHidden: true,
		},
	},
	{
		path: "/home",
		name: "home",
		component: () => import("@/pages/Home"),
	},
	{
		path: "/search/:keyword?",
		name: "search",
		component: () => import("@/pages/Search"),
	},
	{
		path: "/detail/:skuId",
		name: "detail",
		component: () => import("@/pages/Detail"),
	},
	{
		path: "/addCartSuccess",
		name: "addCartSuccess",
		component: () => import("@/pages/AddCartSuccess"),
		beforeEnter: (to, from, next) => {
			if (from.name === "detail") {
				next();
			} else {
				next("/detail");
			}
		},
	},
	{
		path: "/shopCart",
		name: "shopCart",
		component: () => import("@/pages/ShopCart"),
	},
	{
		path: "/trade",
		name: "trade",
		component: () => import("@/pages/Trade"),
		beforeEnter: (to, from, next) => {
			if (from.name === "shopCart") {
				next();
			} else {
				next("/shopCart");
			}
		},
	},
	{
		path: "/pay",
		name: "pay",
		component: () => import("@/pages/Pay"),
		beforeEnter: (to, from, next) => {
			if (from.name === "trade") {
				next();
			} else {
				next("/shopCart");
			}
		},
	},
	{
		path: "/paySuccess",
		name: "paySuccess",
		component: () => import("@/pages/PaySuccess"),
		beforeEnter: (to, from, next) => {
			if (from.name === "pay") {
				next();
			} else {
				next("/shopCart");
			}
		},
	},
	{
		path: "/center",
		// name: "center",
		component: () => import("@/pages/Center"),
		redirect: "/center/myOrder",
		children: [
			{
				path: "myOrder",
				name: "myOrder",
				component: () => import("@/pages/Center/components/MyOrder"),
			},
			{
				path: "teamOrder",
				name: "teamOrder",
				component: () => import("@/pages/Center/components/TeamOrder"),
			},
		],
	},
];
